package cn.panda.edu.student;

import java.util.Date;
import java.util.Map;


import cn.panda.edu.service.EnrollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


import cn.panda.edu.model.Enter;
import cn.panda.edu.util.FileUtil;
import cn.panda.edu.util.ResultDataUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * 类描述：  报名信息处理
 */
@RestController("/api/student")
@Api(description="报名模块")
public class EnrollController {

	@Autowired
	private EnrollService enrollService ;
	
	@ApiOperation(value="报名成功，信息插入报名表", notes="根据学生id获取该学生所有成绩")
	@ApiImplicitParam(name="pageIndex",value="当前页码",required=true,dataType="int",paramType="form")
	@RequestMapping(value = "/register")
	public Map<String, Object> register(Enter enter, MultipartFile file) throws Exception{
		String fileNameString = FileUtil.uploadFile(file) ;
		enter.setEnterPhoto(fileNameString);
		enter.setEnterDate(new Date());
		if (enrollService.insertEnter(enter) > 0) {
			return ResultDataUtil.resData(200, "报名成功", null) ;
		} else {
			return ResultDataUtil.resData(500, "报名失败", null) ;
		}
	}
}

















